/*
 * defs.h
 *
 *  Created on: Jan 30, 2012
 *      Author: Andrew Jeffery
 */

#include <stdint.h>

#ifndef DEFS_H_
#define DEFS_H_

#define MAX_FLOORS 10
#define BUF_SIZE 256

#define SERVER_ADDR "127.0.0.1"
#define SERVER_PORT 8000

#define GUI_ADDR "127.0.0.1"
#define GUI_PORT 8001

#define BUFFER_SIZE 10
#define COMM_MANAGER_BUFFER_ID 0

#define STATUS_UPDATE_PERIOD 75000000

#define SLEEP1S rt_timer_ns2ticks(1000000000)

//Message types that are sent between the client and server
enum MSGTYPES {
	STATUS_REPLY,
	STATUS_REQUEST,
	CAR_ERROR,
	FLOOR_REQUEST,
	GUI_REPLY,
	KILL_MSG,
	EC_INIT_MSG,
	EVENT_MSG
};

enum TESTPOINTS {
	ARRIVAL = 1,
	DEPARTED,
	NEXT_FLOOR
};

typedef struct srep {
	int8_t type;
	int8_t car;
	int8_t cur_floor;
	int8_t dest_floor;
	int8_t status;
	int8_t direction;
	int8_t cur_hall_calls[MAX_FLOORS];
}srep_t;

//Constant defines for status variable

enum STATUSTYPES{
	SPOOLING,
	MOVING,
	OPENING,
	CLOSING,
	STOPPED
};

enum DIRECTIONS{
	UP,
	DOWN
};

enum DOORSTATES{
	OPEN,
	CLOSE
};

typedef struct sreq {
	int8_t type;
//int8_t car;
	int8_t new_hall_calls[MAX_FLOORS];
	int8_t cancel_hall_calls[MAX_FLOORS];
}sreq_t;


struct cerr {
	int8_t type;
	int8_t car;
	int8_t err_code;
	int8_t floor;
	int8_t direction;
	int8_t hall_calls[MAX_FLOORS];
};

typedef struct ecinitrep {
	int8_t type;
	int8_t car;
}ecinitrep_t;

typedef struct flreq{
	int8_t type;
	int8_t destfloor;
}floor_req_t;

typedef struct test_time_stamp_msg{
	int8_t type;
	int8_t event;
	int8_t car;
	int8_t floor;
	int32_t timestamp;
}test_stamp_t;


enum ERROR_CODES {
	DOOR_JAM,
	FIRE_ALARM,
	EMG_STOP,
	SERVICE
};
#endif /* DEFS_H_ */
